from llama_index.llms.openai import OpenAI 
from llama_index.core.chat_engine import SimpleChatEngine
from typing import Dict

from llama_index.llms.openai import OpenAI as DeepSeeK
from openai import OpenAI


# 添加deepseek模型，无需改源码
from llama_index.llms.openai.utils import ALL_AVAILABLE_MODELS, CHAT_MODELS
DEEPSEEK_MODELS: Dict[str, int] = {
    "deepseek-chat": 128000,
}
ALL_AVAILABLE_MODELS.update(DEEPSEEK_MODELS)
CHAT_MODELS.update(DEEPSEEK_MODELS)

def deepseek_llm(**kwargs):
    llm = DeepSeeK(api_key='sk-79fa0380ce9c4c3297e51451baab0d09',
                 model="deepseek-chat",
                 api_base="https://api.deepseek.com/v1",
                 temperature=0.7,
                 **kwargs)
    return llm
from llama_index.core import Settings
Settings.llm = deepseek_llm()

chat_engine=SimpleChatEngine.from_defaults()
chat_engine.streaming_chat_repl()